package main.leetcode.offer.secondround.from03to50;

/** 05.替换空格 */
public class ex05 {
    public String replaceSpace(String s) {
        char[] chars = new char[s.length() * 3];
        int sz = 0;
        for (int i = 0; i < s.length(); ++i) {
            if (s.charAt(i) == ' ') {
                chars[sz++] = '%';
                chars[sz++] = '2';
                chars[sz++] = '0';
            } else {
                chars[sz++] = s.charAt(i);
            }
        }
        return new String(chars, 0, sz);
    }
}
